package KnowSparkSQL.DSL.DatasetMethods.CreateDataset;


import org.apache.spark.sql.Dataset;
import org.apache.spark.sql.Row;
import org.apache.spark.sql.SparkSession;

public class CreateDataset {
    public static void main(String[] args) {
        /**
         * 1. 使用sparkSession.read.json(String path)创建DataFrame对象
         */
        // 创建 sparkSession对象
        SparkSession ss = SparkSession.builder()
                .appName("CreateDataset")

                .master("local")
                // 创建sparkSession对象
                .getOrCreate();
        // 调用sparkSession对象得到一个DataFrameReader对象
        Dataset<Row> people = ss.read()

                .json("./data/people.json");

        people.show();
        people.printSchema();

    }
}
